package com.itcast.manager3.C_service;

import com.itcast.manager2.E_domain.Student;
import com.itcast.manager3.D_dao.StudentDao;
import com.itcast.manager3.tomian.StudentTomain;

import java.util.ArrayList;

public class StudentService {
    private StudentDao sd = new StudentDao();
    public void addStudent(StudentTomain stu) {
            sd.addStudent(stu);
    }

    public boolean isExists(String id) {
        ArrayList<StudentTomain> list = sd.getAllList();
        for (int i = 0; i < list.size(); i++) {
            StudentTomain stu = list.get(i);
            if (stu.getId().equals(id)){
                return true;
            }
        }
        return false;
    }

    public void deleteStudent(String id) {
        sd.deleteStendet(id);
    }

    public ArrayList<StudentTomain> getAllStudent() {
        ArrayList<StudentTomain > list = sd.getAllList();
         return list;
    }

    public void updateStudent(StudentTomain stu) {
        sd.updateStendt(stu);
    }
}
